package cool.lichuan.config;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.dreamlu.iot.mqtt.core.server.event.IMqttConnectStatusListener;
import org.springframework.stereotype.Component;
import org.tio.core.ChannelContext;

/**
 * MQTT服务端上下线监听
 *
 * @author lichuan
 * @since 2025/6/7 19:52
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class MqttConnectStatusListener implements IMqttConnectStatusListener {

    @Override
    public void online(ChannelContext context, String clientId, String username) {
        log.info("设备【{}】上线",  clientId);
    }

    @Override
    public void offline(ChannelContext context, String clientId, String username, String reason) {
        log.warn("设备【{}】离线",  clientId);
    }
}
